#!/bin/bash

# 安装NTP服务
if ! command -v ntpd >/dev/null 2>&1; then
    if command -v yum >/dev/null 2>&1; then
        yum install -y ntp
    elif command -v apt-get >/dev/null 2>&1; then
        apt-get install -y ntp
    else
        echo "无法安装 NTP 服务"
        exit 1
    fi
fi

# 启用并启动NTP服务
systemctl enable ntpd
systemctl start ntpd

echo "NTP服务配置完成"

